# Problem 5
# =========
# 2520 is the smallest number that can be divided
# by each of the numbers from 1 to 10 without any
# remainder.
#
# What is the smallest positive number 
# that is evenly divisible by all of the numbers
# from 1 to 20?

MAX = 20
MIN =  2
POW =  2
factors = {} 

# first, sieve for primes
for n in range(MIN, MAX+1):
    if len([i for i in factors if n%i==0])==0:
        factors[n] = n

# next filter for powers
while MIN**POW < MAX:
    powers = [n for n in factors if n**POW <= MAX]
    for p in powers:
        factors[p] = p**POW
    POW += 1

answer = reduce(lambda x,y: x*y, factors.values())

f = factors.values()
f.sort()
print "-> ", f 
print "-> ", answer
